//
//  HLTgonghuiuserViewController.m
//  huiliantong
//
//  Created by hlt on 15/10/23.
//  Copyright © 2015年 hlt. All rights reserved.
//
#import "HLTgonghuiuserViewController.h"
//#import "HLTusergongnengCollectionViewCell.h"
#import "HLTgonghuigongnengCollectionViewCell.h"
//#import "HLTgonghuigongnengTableViewCell.h"
#import "HLTgonghuititleCollectionViewCell.h"
//#import "HLTusertitleCollectionViewCell.h"
#import "HLTLoginTableViewController.h"
//#import "HLTBandcardTableViewController.h"
#import "HLTBandcardViewController.h"
#import "SliderViewController.h"
//导入支付吗管理需要用到得四个控制器
#import "HLTquanbuTableViewController.h"

#import "HLTorderTableViewController.h"

#import "HLTzhuanzhangTableViewController.h"

#import "HLTUpdatecardpasswordTableViewController.h"

#import "HLTUpdatapasswordTableViewController.h"

#import "HLTCustomerserviceTableViewController.h"

#import "HLTmyuserinfoTableViewController.h"

#import "HLTuserchargeViewController.h"

#import "HLTgonghuifanliViewController.h"

#import "HLTzhangdanViewController.h"

//#import "HLTgonghuizhangdanViewController.h"



@interface HLTgonghuiuserViewController ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout,sliderScrollerDelegate>

@property  UICollectionView *testcollection;

@property NSMutableArray *imageary;
@property NSMutableArray *gongnengary;



@end

@implementation HLTgonghuiuserViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //这个是必须要注册的，不然会崩溃
    //     [self.testcollection registerClass:[HLTusergongnengCollectionViewCell class] forCellWithReuseIdentifier:@"HLTusergongnengCollectionViewCell"];
    self.biaozhi=0;
    
    //设置返回的按钮的字体的颜色的
    self.navigationController.navigationBar.tintColor=[UIColor whiteColor];
    //设置导航的背景颜色的
    self.navigationController.navigationBar.barTintColor = navigationBarColor;
    
    self.zhanneixincount=@"0";
    
    //初始化功能图片数组和文字数组
    _imageary=[NSMutableArray arrayWithObjects:@"卡片绑定",@"我的订单",@"转账",@"支付码",@"卡密码修改",@"登录密码修改",@"个人资料",@"客服",@"充值",@"fanlilist",@"交易明细",@"卡交易明细",nil];
    //    /NSMutableArray *array = [NSMutableArray arrayWithObjects:@"One",@"Two",@"Three",nil];
    _gongnengary=[NSMutableArray arrayWithObjects:@"卡绑定",@"我的订单",@"转账",@"支付码管理",@"卡密码修改",@"登录密码修改",@"个人资料",@"在线客服",@"充值",@"返利明细",@"线上明细",@"卡资金明细",nil];
    
    //初始化
    UICollectionViewFlowLayout *flowLayout=[[UICollectionViewFlowLayout alloc] init];
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing=0;
    self.testcollection = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, screen_width,screen_height)collectionViewLayout:flowLayout];
    //注册
    [self.testcollection registerClass:[HLTgonghuititleCollectionViewCell class]forCellWithReuseIdentifier:@"HLTgonghuititleCollectionViewCell"];
    [self.testcollection registerClass:[HLTgonghuigongnengCollectionViewCell class]forCellWithReuseIdentifier:@"HLTgonghuigongnengCollectionViewCell"];
    //设置代理
    self.testcollection.delegate = self;
    self.testcollection.dataSource = self;
    self.testcollection.backgroundColor=RGB(255, 255, 255);
//    self.testcollection.backgroundColor=[UIColor whiteColor];
    
    [self.view addSubview:self.testcollection];
    
    
    
    
  
    
    
}







#pragma mark <UICollectionViewDataSource>

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 2;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    if (section==0) {
        return 1;
    }else
        return [_imageary count];;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section==0) {
        NSString *identify1 = @"HLTgonghuititleCollectionViewCell";
        HLTgonghuititleCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:identify1 forIndexPath:indexPath];
        
        [cell initview];
        
        cell.parent=self;
        cell.xiaoxicount.text=self.zhanneixincount;
        //        cell.titleimage.image=[UIImage imageNamed:@"bandHui"];
        //        cell.buttontitle.text=@"汇联通卡绑定";
        //设置每一个cell的边框颜色和宽度
        //        cell.layer.borderColor=[UIColor grayColor].CGColor;
        //        cell.layer.borderWidth=1;
        return cell;
    }
    else
    {
        
        static NSString *identify = @"HLTgonghuigongnengCollectionViewCell";
        HLTgonghuigongnengCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:identify forIndexPath:indexPath];
        
        
        NSLog(@"%ld",(long)indexPath.row);
        
        cell.titleimage.image=  [UIImage imageNamed:_imageary[indexPath.row]] ;
        cell.buttontitle.text=_gongnengary[indexPath.row];
        
        //设置每一个cell的边框颜色和宽度
        cell.layer.borderColor=RGB(241, 241, 241).CGColor;
//        cell.layer.borderColor=[UIColor grayColor].CGColor;
        cell.layer.borderWidth=0.4;
        return cell;
    }
}


-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    
    if (indexPath.section==1) {
        
        if (indexPath.row==0) {
            
            
            
            [EYInputPopupView popViewWithTitlenumber:@"请输入登陆密码" contentText:@"登陆密码"
                                                type:EYInputPopupView_Type_single_line_text
                                         cancelBlock:^{
                                             
                                         } confirmBlock:^(UIView *view, NSString *text) {
                                             
                                             Account *acc=[[AccountTool sharedAccountTool] currentAccount];
                                             
                                             
                                             if ([acc.pwd isEqual:text]) {
                                                 
                                                 
                                                 
                                                 UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                                                 HLTBandcardViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTBandcardViewController"];
                                                 vc.hidesBottomBarWhenPushed = YES;
                                                 [self.navigationController pushViewController:vc animated:NO];
                                                 
                                                 
                                             }else
                                             {
                                                 self.biaozhi=self.biaozhi+1;
                                                 if (self.biaozhi>=5) {
                                                     
                                                     UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"提示" message:@"您输入的密码错误次数超过5次，将清空登陆信息，并返回上一个界面" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
                                                     
                                                     [alert show];
                                                     Account *acc=[[AccountTool sharedAccountTool] currentAccount];
                                                     //退出登录
                                                     [[AccountTool sharedAccountTool] tuichu:acc];
                                                     [self.navigationController popViewControllerAnimated:YES];
                                                     
                                                 }
                                                 else
                                                 {
                                                     
                                                     NSString *str=[NSString stringWithFormat:@"您输入的密码不对,还有%ld次输入机会",5-self.biaozhi];
                                                     
                                                     UIAlertView *alert= [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:nil cancelButtonTitle:nil otherButtonTitles:@"好", nil];
                                                     
                                                     [alert show];
                                                 }
                                                 
                                                 
                                             }
                                             
                                             
                                         } dismissBlock:^{
                                             
                                         }];
            
            
        }else if (indexPath.row==3)
        {
            NSMutableArray * array=[NSMutableArray array];
            
            NSArray * titiles=@[@"全部",@"有效",@"交易完成"];
            for (int i=0; i<titiles.count; i++) {
                
                if (i==0) {
                    HLTquanbuTableViewController *nex1= [[HLTquanbuTableViewController alloc] init];
                    nex1.type=quanbu;
                    [array addObject:nex1];
                }
                else if (i==1)
                {
                    HLTquanbuTableViewController *nex1= [[HLTquanbuTableViewController alloc] init];
                    nex1.type=youxiao;
                    
                    
                    [array addObject:nex1];
                    
                }else if (i==2)
                {
                    HLTquanbuTableViewController *nex1= [[HLTquanbuTableViewController alloc] init];
                    nex1.type=wuxiaio;
                    [array addObject:nex1];
                }
                //                    else if (i==3)
                //                {
                //                     HLTquanbuTableViewController *nex1= [[HLTquanbuTableViewController alloc] init];
                //                    nex1.type=weishiyong;
                //                    [array addObject:nex1];
                //                }
            }
            
            
            SliderViewController * next=[[SliderViewController alloc] initWithViewControllers:array];
            
            for (int i=0; i<[array count]; i++) {
                
                HLTquanbuTableViewController *vcc=array[i];
                vcc.parent=next;
                
            }
            
            
            next.titileArray=titiles;
            next.lineHeight=2;
            next.selectTextColor=navigationBarColor;
            
            next.selectBgColor=[UIColor whiteColor];
            next.defaultUnSelectBgColor=[UIColor lightGrayColor];
            // next.separateColor=[UIColor redColor];
            next.selectIndex=0;
            next.sliderDelegate=self;
            next.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:next animated:YES];
            
        }
        else if (indexPath.row==2)
        {
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTzhuanzhangTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTzhuanzhangTableViewController"];
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:NO];
            
        }else if (indexPath.row==1)
        {
            NSMutableArray * array=[NSMutableArray array];
            
            //            NSArray * titiles1=@[@"全部",@"退款中",@"退款完成",@"拒绝退款",@"交易完成",@"待确认"];
            
            NSArray * titiles=@[@"待确认",@"退款中",@"退款成功",@"拒绝退款",@"交易完成"];
            for (int i=0; i<titiles.count; i++) {
                
                if (i==0) {
                    HLTorderTableViewController *nex1= [[HLTorderTableViewController alloc] init];
                    nex1.type=ketuikuan;
                    [array addObject:nex1];
                }
                else if (i==1)
                {
                    HLTorderTableViewController *nex1= [[HLTorderTableViewController alloc] init];
                    nex1.type=tuikuanzhong;
                    
                    
                    [array addObject:nex1];
                    
                }else if (i==2)
                {
                    HLTorderTableViewController *nex1= [[HLTorderTableViewController alloc] init];
                    nex1.type=tuikuanchenggong;
                    [array addObject:nex1];
                }else if (i==3)
                {
                    HLTorderTableViewController *nex1= [[HLTorderTableViewController alloc] init];
                    nex1.type=jujuetuikiuan;
                    [array addObject:nex1];
                }else if (i==4)
                {
                    HLTorderTableViewController *nex1= [[HLTorderTableViewController alloc] init];
                    nex1.type=jiaoyiwancheng;
                    [array addObject:nex1];
                }
            }
            
            
            SliderViewController * next=[[SliderViewController alloc] initWithViewControllers:array];
            
            
            for (int i=0; i<[array count]; i++) {
                
                HLTorderTableViewController *vcc=array[i];
                vcc.parent=next;
                
            }
            
            
            
            
            //            next.tag=1005;
            next.titileArray=titiles;
            next.lineHeight=2;
            next.selectTextColor=navigationBarColor;
            
            next.selectBgColor=[UIColor whiteColor];
            next.defaultUnSelectBgColor=[UIColor lightGrayColor];
            // next.separateColor=[UIColor redColor];
            next.selectIndex=0;
            next.sliderDelegate=self;
            next.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:next animated:YES];
            
            
            
        }else if (indexPath.row==4)
        {
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTUpdatecardpasswordTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTUpdatecardpasswordTableViewController"];
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:NO];
            
            
        }else if (indexPath.row==5)
        {
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTUpdatapasswordTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTUpdatapasswordTableViewController"];
            vc.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:vc animated:NO];
            
        }else if (indexPath.row==6)
        {
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTmyuserinfoTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTmyuserinfoTableViewController"];
            
            vc.hidesBottomBarWhenPushed = YES;
            
            //            HLTCustomerserviceTableViewController *vc =[[HLTCustomerserviceTableViewController alloc]init];
            [self.navigationController pushViewController:vc animated:NO];
            
        }else if (indexPath.row==7)
        {
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTCustomerserviceTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTCustomerserviceTableViewController"];
            
            vc.hidesBottomBarWhenPushed = YES;
            
            //            HLTCustomerserviceTableViewController *vc =[[HLTCustomerserviceTableViewController alloc]init];
            [self.navigationController pushViewController:vc animated:NO];
            
        }else if (indexPath.row==8)
        {
            
            
            
                                             Account *acc=[[AccountTool sharedAccountTool] currentAccount];
            NSString *url=[NSString stringWithFormat:@"%@&user_name=%@",usercharge,acc.custPhone];
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTuserchargeViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTuserchargeViewController"];
            vc.hidesBottomBarWhenPushed = YES;
            vc.url=url;
            //            [vc setmywebview];
            
            //            HLTCustomerserviceTableViewController *vc =[[HLTCustomerserviceTableViewController alloc]init];
            [self.navigationController pushViewController:vc animated:NO];
            
            
        }
        else if (indexPath.row==9)
        {
            
//            Account *acc=[[AccountTool sharedAccountTool] currentAccount];
            //
//            NSString *url=[NSString stringWithFormat:@"%@&card_num=%@",fanlilist,acc.cardNo];
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTgonghuifanliViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTgonghuifanliViewController"];
            vc.hidesBottomBarWhenPushed = YES;
//            vc.url=url;
//            [vc setmywebview];
            
            //            HLTCustomerserviceTableViewController *vc =[[HLTCustomerserviceTableViewController alloc]init];
            [self.navigationController pushViewController:vc animated:NO];
            
            
        }
        else if (indexPath.row==10)
        {
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTzhangdanViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTzhangdanViewController"];
            vc.jiaoyitype=@"xianshang";
            [self.navigationController pushViewController:vc animated:YES]; //跳转到下一页面
            
            
        }else if (indexPath.row==11)
        {
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTzhangdanViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTzhangdanViewController"];
            vc.jiaoyitype=@"xianxia";
            [self.navigationController pushViewController:vc animated:YES]; //跳转到下一页面
            
            
            
            
            
            
        }
        
        
        
        
        
        
    }
    
    
    
}




#pragma mark <UICollectionViewDelegate>

//定义每个UICollectionView 的大小
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
    if (indexPath.section==0) {
        
        CGSize headerSize = CGSizeMake(screen_width,screen_width/1.8);
        return headerSize;
        
        
    }
    else
    {
        CGSize headerSize = CGSizeMake(screen_width/4.0,screen_width/4.0+10);
        return headerSize;
    }
    
}


#pragma mark slider的委托

-(void)sliderScrollerDidIndex:(NSInteger)index andSlider:(SliderViewController *)slider{
    
    NSString * tiitle=slider.titileArray[index];
    slider.title=tiitle;
}



//定时器的回调方法
-(void) task
{
    //定时刷新用户数据
    
    Account *acc=[[AccountTool sharedAccountTool]currentAccount];
    
    //自定检查登录的函数
    [self customlogin:acc.custPhone password:acc.pwd];
    
   
    
    
    NSString *url=[jianchazhanneixin stringByAppendingFormat:@"&username=%@",acc.custPhone];
    //将url转换一下格式，否则请求的格式就不兼容
    //    url = [url stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
    [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
        //        NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
        //        NSString *str = [numberFormatter stringFromNumber:ary[@"11"]];
        //
        
        if ([ary count]>0) {
            
            
            
            NSArray *keyary=[ary allKeys];
            int num=0;
            //通过下面这个循环得到消息总数
            for (int i=0; i<[keyary count]; i++) {
                num+=[ary[keyary[i]] intValue];
            }
            
            NSString *strcoun=[NSString stringWithFormat:@"%d",num];
            
            self.zhanneixincount=strcoun;
            NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:0];
            [self.testcollection reloadSections:indexSet];
            
        }
        
    } faliure:^(NSString *error) {
        
    }];
    
    
    
    
    
    
    
}


//即将出现调用的方法
-(void) viewWillAppear:(BOOL)animated
{
    
    
    //开启定时器
    [self.connectionTimer setFireDate:[NSDate distantPast]];
    
    
    //隐藏tabbar的方法
    //    self.hidesBottomBarWhenPushed = NO;
    
    //     [self.tab setTabBarHidden:YES];
    Account *acc=[[AccountTool sharedAccountTool] currentAccount];
    
    if ([acc.pwd isEqualToString:@""]) {
        
        
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        HLTLoginTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTLoginTableViewController"];
        
        [self.navigationController pushViewController:vc animated:NO];
        
    }else
    {
        if (!acc) {
            
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTLoginTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTLoginTableViewController"];
            [self.navigationController pushViewController:vc animated:NO];
            
        }else{
            
            
            [self.testcollection reloadData];
            
            NSDate *scheduledTime = [[NSDate alloc]init];
            NSString *customUserObject = @"To demo userInfo";
            self.connectionTimer = [[NSTimer alloc] initWithFireDate:scheduledTime
                                                            interval:30
                                                              target:self
                                                            selector:@selector(task)
                                                            userInfo:customUserObject
                                                             repeats:YES];
            NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
            [runLoop addTimer:self.connectionTimer forMode:NSDefaultRunLoopMode];
            
            
            
        }
        
        
        
        
    }
    
    
    
    
    
}








//即将消失调用的方法
- (void)viewWillDisappear:(BOOL)animated
{
    //停止定时器
//    [self.connectionTimer invalidate];
    
    //关闭定时器
    [self.connectionTimer setFireDate:[NSDate distantFuture]];
    
    //隐藏tabbar(这个得值在使用storyborad时yes是显示，没有使用时yes是不显示)
    //    self.hidesBottomBarWhenPushed = YES;
    
}













-(void) customlogin:(NSString *)username password:(NSString *)pwd
{
    
    
    //base64 编码
    NSString *base64pwd= [SetBase64andMd5 base64:pwd ncryptOrDecrypt:kCCEncrypt];
    
    NSString *url=[loginurl stringByAppendingFormat:@"&username=%@&password=%@",username,base64pwd];
    [HLTNetWorkingtool getyouhuilist:url success:^(NSMutableArray *ary) {
        
        //        NSArray *aaary=ary;
        NSDictionary *dic=ary[0];
        NSLog(@"%@",dic[@"bind_card"]);
        if ([dic[@"status"] isEqual:@"0"]) {
            
            if ([dic[@"bind_card"] isEqual:@"0"]||[dic[@"bind_card"] isEqual:@"00"]) {
                Account *acc=[[AccountTool sharedAccountTool] currentAccount];
                
                //加这个条件是为了防止已经点击了退出按钮之后这里还执行导致失败
                if (![acc.pwd isEqual:@""]) {
                
                acc.pwd=pwd;
                acc.custPhone=username;
                acc.custFlag=dic[@"user_rank"];
                acc.cardNo=@"";
                [[AccountTool sharedAccountTool] addAccounts:acc];
                }
            }
            else
            {
                
                
                
                NSString *url=[chaxunyue stringByAppendingFormat:@"&user_name=%@&cardNum=%@",username,dic[@"bind_card"]];
                [HLTNetWorkingtool getdic:url success:^(NSDictionary *ary) {
                    
                    
                    if ([ary[@"status"] isEqual:@"0"]) {
                        Account *acc=[[AccountTool sharedAccountTool] currentAccount];
                        //加这个条件是为了防止已经点击了退出按钮之后这里还执行导致失败
                        if (![acc.pwd isEqual:@""]) {
                        acc.pwd=pwd;
                        acc.cardNo=dic[@"bind_card"];
                        acc.custFlag=dic[@"user_rank"];
                        acc.custPhone=username;
                        acc.YKTCardBalance=ary[@"deposit"];
                        [[AccountTool sharedAccountTool] addAccounts:acc];
                        }
                        NSLog(@"%@",ary);
                        //                        [self.navigationController popViewControllerAnimated:YES];
                        
                    }else
                    {
                        
                        
                    }
                } faliure:^(NSString *error) {
                    
                    
                }];
            }
            
            
            
        }else
        {
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"您的登录信息已改变。请重新登录"   message:dic[@"msg"]  delegate:nil cancelButtonTitle:@"好" otherButtonTitles: nil];
            [alert show];
            UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
            HLTLoginTableViewController *vc = [storyBoard instantiateViewControllerWithIdentifier:@"HLTLoginTableViewController"];
            
            [self.navigationController pushViewController:vc animated:NO];
            
            
        }
        
        
        
        
    } faliure:^(NSString *error) {
        
        
        
    }];
    
}



- (void) getnicehng
{
    Account *acc=[[AccountTool sharedAccountTool]currentAccount];
    NSString *url=[chaxunuserinfo stringByAppendingFormat:@"&username=%@",acc.custPhone];
    [HLTNetWorkingtool getary:url success:^(NSArray *ary) {
        
        NSString *name;
        if ([ary[0][@"name"] isEqual:[NSNull null]]) {
            name=@"未设置";
        }
        else
        {
            name=ary[0][@"name"];
            
        }
        
        acc.custName=name;
        
        
        NSString *sex;
        if ([ary[0][@"sex"] isEqual:@"1"]) {
            
            sex=@"男";
        }else
        {
            sex=@"女";
        }
        acc.custSex=sex;
        [[AccountTool sharedAccountTool] addAccounts:acc];
        
        
    } faliure:^(NSString *error) {
        
        
    }];
    
    
    
    
}














- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
